﻿using System;
using System.ComponentModel.DataAnnotations;
using hello.csharp.domain.Base;
using Newtonsoft.Json;

namespace hello.csharp.domain
{
    public class User : BaseDomain
    {
        [MaxLength(32)] public string Nickname { get; set; }

        public ushort Sex { get; set; }

        public string Address { get; set; }

        /// <summary>
        ///     手机号杩
        /// </summary>
        [MaxLength(11)]
        public string Mobile { get; set; }

        /// <summary>
        ///     手机号杩是否确认的标记
        /// </summary>
        public bool MobileConfirmed { get; set; } = false;

        public string Roles { get; set; }

        [MaxLength(128)] public string Email { get; set; }

        /// <summary>
        ///     邮件是否确认的标记
        /// </summary>
        public bool EmailConfirmed { get; set; } = false;

        /// <summary>
        ///     指示这个用户可不可以被锁定
        /// </summary>
        public bool LockoutEnabled { get; set; }

        /// <summary>
        ///     指定锁定的到期日期，null 或者一个过去的时间，代表这个用户没有被锁定
        /// </summary>
        public DateTime LockoutEnd { get; set; }

        /// <summary>
        ///     用来记录用户尝试登陆却登陆失败的次数，通过该值来确定在什么时候需要锁定用户
        /// </summary>
        public uint AccessFailedCount { get; set; }

        #region Overrides of Object

        /// <inheritdoc />
        public override string ToString()
        {
            return JsonConvert.SerializeObject(this, Formatting.Indented);
        }

        #endregion
    }
}